
package cn.javaxc.mvcwork.modules.admin;
import cn.javaxc.mvcwork.framework.beans.TFormBean;
import cn.javaxc.mvcwork.util.common.DatabaseUtils;
import java.sql.*;
import java.text.DateFormat;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;





public class Role extends TFormBean {

  private static final long serialVersionUID = 3296299115328316895L;
  //Role Properties
  protected int id = -1;
  protected String role = null;
  protected String description = null;
  protected int roleType = -1; //regular or portal user type (engineer, customer...etc)
  protected java.sql.Timestamp entered = null;
  protected java.sql.Timestamp modified = null;
  protected int enteredBy = -1;
  protected int modifiedBy = -1;
  protected boolean enabled = true;
  //Helper Properties
  protected int userCount = -1;
  //Related Collections
  //Rules for building object
  protected boolean buildHierarchy = false;


  
  public Role() {
  }


  
  public Role(ResultSet rs) throws SQLException {
    buildRecord(rs);
  }


  
  public void setEntered(java.sql.Timestamp tmp) {
    this.entered = tmp;
  }


  
  public void setEntered(String tmp) {
    this.entered = DatabaseUtils.parseTimestamp(tmp);
  }


  
  public void setModified(java.sql.Timestamp tmp) {
    this.modified = tmp;
  }


  
  public void setModified(String tmp) {
    this.modified = DatabaseUtils.parseTimestamp(tmp);
  }


  
  public void setId(int tmp) {
    this.id = tmp;
  }


  
  public void setId(String tmp) {
    this.id = Integer.parseInt(tmp);
  }


  
  public void setRole(String tmp) {
    this.role = tmp;
  }


  
  public void setDescription(String tmp) {
    this.description = tmp;
  }


  
  public void setRoleType(int tmp) {
    this.roleType = tmp;
  }


  
  public void setRoleType(String tmp) {
    this.roleType = Integer.parseInt(tmp);
  }


  
  public void setEnteredBy(int tmp) {
    this.enteredBy = tmp;
  }


  
  public void setEnteredBy(String tmp) {
    this.enteredBy = Integer.parseInt(tmp);
  }


  
  public void setModifiedBy(int tmp) {
    this.modifiedBy = tmp;
  }


  
  public void setModifiedBy(String tmp) {
    this.modifiedBy = Integer.parseInt(tmp);
  }


  
  public void setEnabled(boolean tmp) {
    this.enabled = tmp;
  }


  
  public void setEnabled(String tmp) {
    this.enabled = DatabaseUtils.parseBoolean(tmp);
  }




  
  public void setUserCount(int tmp) {
    this.userCount = tmp;
  }


  
  public void setUserCount(String tmp) {
    this.userCount = Integer.parseInt(tmp);
  }


  
  public java.sql.Timestamp getEntered() {
    return entered;
  }


  
  public java.sql.Timestamp getModified() {
    return modified;
  }


  
  public String getModifiedString() {
    String tmp = "";
    try {
      return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(
          modified);
    } catch (NullPointerException e) {
    }
    return tmp;
  }


  
  public String getEnteredString() {
    String tmp = "";
    try {
      return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(
          entered);
    } catch (NullPointerException e) {
    }
    return tmp;
  }


  
  public int getId() {
    return id;
  }


  
  public String getRole() {
    return role;
  }


  
  public String getDescription() {
    return description;
  }


  
  public int getRoleType() {
    return roleType;
  }


  
  public int getEnteredBy() {
    return enteredBy;
  }


  
  public int getModifiedBy() {
    return modifiedBy;
  }


  
  public boolean getEnabled() {
    return enabled;
  }



  
  public int getUserCount() {
    return userCount;
  }




  
  protected void buildRecord(ResultSet rs) throws SQLException {
    //role table
    id = rs.getInt("role_id");
    role = rs.getString("role");
    description = rs.getString("description");
    entered = rs.getTimestamp("entered");
    enteredBy = rs.getInt("enteredby");
    modified = rs.getTimestamp("modified");
    modifiedBy = rs.getInt("modifiedby");
    enabled = rs.getBoolean("enabled");
    roleType = DatabaseUtils.getInt(rs, "role_type");
  }


  
  protected void buildResources(Connection db) throws SQLException {

  }






 
  
  private void insertPermissions(Connection db) throws SQLException {

  }
}
